<?php
	$hostname_logon = 'localhost';      //Database server LOCATION
    $database_logon = 'wwwmsc_newcareer';       //Database NAME
    $username_logon = 'wwwmsc';       //Database USERNAME
    $password_logon = 'Slpnxhe}bX4h';       //Database PASSWORD
	$database_connection = mysql_connect($hostname_logon,$username_logon,$password_logon) or die("couldnt connect with mysql");
	$database_selection = mysql_select_db($database_logon,$database_connection);
	
	$field_type = $_REQUEST["field_type"];
	$field_value = $_REQUEST["field_value"];
	$user_id = $_REQUEST["user_id"];
	
	if($user_id > 0)
	{
		$extra_condition = " and user_id != '".$user_id."'";
	}
	else
	{
		$extra_condition = "";
	}
	
	if($field_type == "")
	{
		echo "Please enter type of validation";
	}
	else if($field_type == "user_name")
	{
		if($field_value == "")
		{
			echo "Please enter username";
		}
		else
		{
			$select_query = "select user_id from USERS where `user_name` = '$field_value' $extra_condition";
			$select_result = mysql_query($select_query) or die(mysql_error());
			$select_total = mysql_num_rows($select_result);
			if($select_total > 0)
			{
				$select_data = mysql_fetch_array($select_result);
				echo $select_data["user_id"];
			}
			else
			{
				echo "no_conflict";
			}
		}		
	}
	else if($field_type == "user_email")
	{
		if($field_value == "")
		{
			echo "Please enter email";
		}
		else
		{
			$select_query = "select user_id from USERS where `user_email` = '$field_value' $extra_condition";
			$select_result = mysql_query($select_query) or die(mysql_error());
			$select_total = mysql_num_rows($select_result);
			if($select_total > 0)
			{
				$select_data = mysql_fetch_array($select_result);
				echo $select_data["user_id"];
			}
			else
			{
				echo "no_conflict";
			}
		}		
	}
?>